package com.springcloud.tread.controller;

import com.springcloud.tread.pojo.Index;
import com.springcloud.tread.pojo.IndexData;
import com.springcloud.tread.service.IndexDataService;
import com.springcloud.tread.service.StoreSerice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class StoreController {

    @Autowired
    StoreSerice storeSerice;
    @Autowired
    IndexDataService indexDataService;

    @RequestMapping("/store/get")
    public List<Index> getData() {
        return storeSerice.get();
    }

    @RequestMapping("/store/remove")
    public String remove() {
        storeSerice.reomve();
        return "删除成功！！";
    }

    @RequestMapping("/store/fresh")
    public List<Index> fresh() {
        return storeSerice.fresh();
    }

    //先删除
    //获取-->得到空数据
    //再刷新得到新数据-->得到新数据


    /**
     * 操作指数数据
     */

    @GetMapping("/store/freshIndexData/{id}")
    public List<IndexData> freshIndexdata(@PathVariable String id) {
        System.out.println(id);
        return indexDataService.fresh(id);
    }

    @GetMapping("/store/removeIndexData/{id}")
    public String removeIndexData(@PathVariable String id){
        indexDataService.reomve(id);
        return "IndexData删除成功";
    }

    @GetMapping("/store/getIndexData/{id}")
    public List<IndexData> getIndexData(@PathVariable String id){
        return  indexDataService.get(id);
    }

    //先增加数据--->数据显示
    //再删除数据
    //再获取数据---》为空
    //增加数据
    //再获取数据-->使用get
}
